<template>
  <d2-container>
    <div class="content">
      <div class="main">
        <el-row :gutter="24">
          <h3>商户号:{{ machInfo.mchNo }}</h3>
          <h3>商户名称:{{ machInfo.mchName }}</h3>
          <h3>注册状态:{{ machInfo.strRegStatus }}</h3>
          <h3 v-if="machInfo.editStatus == 2">资料状态:{{editStatusList[machInfo.editStatus] }}</h3>
        </el-row>
        <el-row :gutter="24">
          <el-form ref="elForm" class="elForm" :model="formData" :rules="rules" size="medium" label-width="200px">
            <el-col :span="24" class="updata-item">
              <el-form-item label="商户注册邮箱" prop="email" style="flex: 1">
                <el-input v-model="formData.email" placeholder="请输入邮箱" clearable :disabled="clearableFrom" :style="{ width: '76%' }"></el-input>
              </el-form-item>
              <!-- <el-checkbox class="checkbox" v-model="checkedFrom.email">标记修改</el-checkbox> -->
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="手机号码" prop="" style="flex: 1">
                <el-input v-model="formData.mobile" placeholder="请输入手机号码" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.mobile">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="交易网站" prop="url" style="flex: 1">
                <el-input v-model="formData.url" placeholder="请输入交易网站" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.url">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="公司名称" prop="mchName" style="flex: 1">
                <el-input v-model="formData.mchName" placeholder="请输入公司名称" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.mchName">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="注册证书编号" prop="registerCertificateNo" style="flex: 1">
                <el-input v-model="formData.registerCertificateNo" placeholder="请输入注册证书编号" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.registerCertificateNo">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="公司开户行名称" prop="bankAccountName" style="flex: 1">
                <el-input v-model="formData.bankAccountName" placeholder="请输入公司开户行名称" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.bankAccountName">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="开户行账户" prop="bankAccountNo" style="flex: 1">
                <el-input v-model="formData.bankAccountNo" placeholder="请输入开户行账户" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.bankAccountNo">标记修改</el-checkbox>
            </el-col>

            <el-col :span="24" class="updata-item">
              <el-form-item label="开户行行号" prop="bankOpenBankNo" style="flex: 1">
                <el-input v-model="formData.bankOpenBankNo" placeholder="请输入开户行行号" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.bankOpenBankNo">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="公司注册地址" prop="registerAddress" style="flex: 1">
                <el-input v-model="formData.registerAddress" placeholder="请选择公司注册地址" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.registerAddress">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="法人/股东/董事名称" prop="corporation" style="flex: 1">
                <el-input v-model="formData.corporation" placeholder="请输入法人/股东/董事名称" clearable :disabled="clearableFrom" :style="{ width: '90%' }"></el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.corporation">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="座机号码" prop="phone" style="flex: 1">
                <el-input v-model="formData.phone" placeholder="请输入座机号码" clearable :disabled="clearableFrom" :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.phone">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="公司注册证书" prop="registerCertList">
                <el-upload list-type="picture-card" :file-list="formData.registerCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :style="{ width: '90%' }" :http-request="
                    (params) => handleFileUpload(params, 'registerCertList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(file, list, 'registerCertList')
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    CR(注册证书)和最新版BR证书(商业等级证)，完整清晰的扫描PDF
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.registerCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="公司章程及组织大纲" prop="companyPoliceList" required>
                <el-upload list-type="picture-card" :file-list="formData.companyPoliceList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) => handleFileUpload(params, 'companyPoliceList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(file, list, 'companyPoliceList')
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.companyPolice">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="注册代理人护照" prop="companyAgentPassportList" required>
                <el-upload list-type="picture-card" :file-list="formData.companyAgentPassportList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) =>
                      handleFileUpload(params, 'companyAgentPassportList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(
                        file,
                        list,
                        'companyAgentPassportList'
                      )
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.companyAgentPassport">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="董事登记册或股东登记册" prop="corporationCertList" required>
                <el-upload list-type="picture-card" :file-list="formData.corporationCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) => handleFileUpload(params, 'corporationCertList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(file, list, 'corporationCertList')
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.corporationCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="董事决议书" prop="corporationDecisionList" required>
                <el-upload list-type="picture-card" :file-list="formData.corporationDecisionList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) =>
                      handleFileUpload(params, 'corporationDecisionList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(
                        file,
                        list,
                        'corporationDecisionList'
                      )
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.corporationDecision">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="法团成立表（nnc）" prop="nncList" required>
                <el-upload list-type="picture-card" :file-list="formData.nncList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) => handleFileUpload(params, 'nncList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(file, list, 'nncList')
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    法团成立表（nnc）需要是完整文件。多页请扫描在一个PDF文件里，不要分页提供
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.nnc">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="公司注册地址的地址证明" prop="registerAddressCertList" required>
                <el-upload list-type="picture-card" :file-list="formData.registerAddressCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) =>
                      handleFileUpload(params, 'registerAddressCertList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(
                        file,
                        list,
                        'registerAddressCertList'
                      )
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    公司注册地址的地址说明，可提供近三个月含注册地址的银行账单，银行开户说明，水电煤气等公共费用账单，办公室租赁合同；完整清晰的扫描PDF;
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.registerAddressCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="银行开户证明/离岸证明" prop="bankAccountNoCertList" required>
                <el-upload list-type="picture-card" :file-list="formData.bankAccountNoCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) =>
                      handleFileUpload(params, 'bankAccountNoCertList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(
                        file,
                        list,
                        'bankAccountNoCertList'
                      )
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    银行开户证明/离岸证明 完整清晰的扫描PDF
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.bankAccountNoCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="法人（董事）证件" prop="legalPersonCertList" required>
                <el-upload list-type="picture-card" :file-list="formData.legalPersonCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) => handleFileUpload(params, 'legalPersonCertList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(file, list, 'legalPersonCertList')
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    法人（董事）身份证/护照/香港永久性居民身份证-正反面材料
                    尽量提供彩色扫描件；
                    董事信息来源于法团成立表director；如存在多位director，至少应该提供一位director材料
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.legalPersonCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="办公场所照片或视频" prop="officeCertList" required>
                <el-upload list-type="picture-card" :file-list="formData.officeCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) => handleFileUpload(params, 'officeCertList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(file, list, 'officeCertList')
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    办公场所照片或视频（包含公司前台LOGO和办公区域）
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.officeCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="周年申报表（nar）" prop="">
                <el-upload list-type="picture-card" :file-list="formData.narList" action="#" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) => handleFileUpload(params, 'narList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(file, list, 'narList')
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    周年申报表（nar）
                    需要是完整文件。多页请扫描在一个PDF文件里，不要分页提供 ;
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.nar">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="25%以上的股东证件信息" prop="">
                <el-upload list-type="picture-card" :file-list="formData.corporation25PercentCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) =>
                      handleFileUpload(params, 'corporation25PercentCertList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(
                        file,
                        list,
                        'corporation25PercentCertList'
                      )
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    25%以上的股东证件信息
                    如股东为个人，需提供护照/身份证扫描件（如果是大陆地区优先提供身份证材料）；
                    如股东为公司，需提供控股公司的注册证书扫描件。
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.corporation25PercentCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="25%以上的股东地址证明" prop="">
                <el-upload list-type="picture-card" :file-list="formData.corporation25PercentAddrCertList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) =>
                      handleFileUpload(
                        params,
                        'corporation25PercentAddrCertList'
                      )
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(
                        file,
                        list,
                        'corporation25PercentAddrCertList'
                      )
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    25%以上的股东地址证明
                    如果股东是个人，可提供近三个月内含居住地址的银行账单、水电煤账单、电话账单、
                    或者在政府开具的税单；如果是公司，可提供近三个月内含注册地址的银行账单、水电煤等公共费用账单或银行开户证明、
                    办公室租赁合同。
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.orporation25PercentAddrCert">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" class="updata-item">
              <el-form-item label="英文版公司股权架构图" prop="">
                <el-upload list-type="picture-card" :file-list="formData.enCompanyStructureList" action="#" :limit="10" multiple :disabled="clearableFrom" :before-upload="BeforeUpload" :on-change="handleFileChange" :on-preview="handlePreview" :http-request="
                    (params) =>
                      handleFileUpload(params, 'enCompanyStructureList')
                  " :on-success="
                    (res, file, list) =>
                      handleFileUploadsucceed(
                        file,
                        list,
                        'enCompanyStructureList'
                      )
                  ">
                  <el-button size="small" :disabled="clearableFrom" type="primary" icon="el-icon-upload">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    英文版公司股权架构图
                    需追溯到持股占25%以上的最终自然人，如A公司持该申请公司股份80%，
                    需追溯到A公司持股占25%以上的自然人；完整清晰的扫描PDF
                  </div>
                </el-upload>
              </el-form-item>
              <el-checkbox class="checkbox" v-model="checkedFrom.enCompanyStructure">标记修改</el-checkbox>
            </el-col>
            <el-col :span="24" v-if=" 
               (( formData.regStatus == 1 && formData.editStatus ==1) || formData.regStatus == 0 ) ||
                (formData.regStatus == 1 && formData.editStatus == 1 || formData.editStatus == 0)
              ">
              <el-form-item label="原因" prop="" style="flex: 1">
                <el-input type="textarea" :rows="4" placeholder="请输入内容" v-model="auditFrom.regRemark" clearable :style="{ width: '90%' }">
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="24" class="footer-btn" v-if="formData.regStatus == 0">
              <el-col :span="4"></el-col>
              <el-col :span="6">
                <el-button type="danger" @click="passMch(3)">审核驳回</el-button>
              </el-col>
              <el-col :span="6">
                <el-button type="warning" @click="passMch(2)">驳回修改</el-button>
              </el-col>
              <el-col :span="6">
                <el-button type="success" @click="passMch(1)">审核通过</el-button>
              </el-col>
            </el-col>

            <el-col :span="24" class="footer-btn" v-if="formData.editStatus == 0 && formData.regStatus != 0">
              <el-col :span="4"></el-col>
              <el-col :span="6">
                <el-button type="warning" @click="editPassMch(2)">驳回修改</el-button>
              </el-col>
              <el-col :span="6">
                <el-button type="success" @click="editPassMch(1)">审核通过</el-button>
              </el-col>
            </el-col>

            <el-col :span="24" class="footer-btn" v-if="formData.regStatus == 1 && formData.editStatus == 1">
              <el-button type="warning" @click="anewMch(2)">要求修改</el-button>
            </el-col>
          </el-form>
        </el-row>
      </div>
    </div>
  </d2-container>
</template>
<script>
import { mapState, mapGetters, mapActions } from "vuex";
// import { updataFileOss } from '@/api/tools.js'
import util from "@/libs/util.js";
import c from 'highlight.js/lib/languages/c';
import ApiMain from '@/api/mch.info';
var _this
export default {
  name: "mch-mchInfo",
  components: {
  },
  props: [],
  // fieldStatus 字段 所有需要修改的字段合集  [{"label": "email", "value": "test", "status": 0, "remark": "通过" },{"label": "mchName", "value": "test", "status": 0, "remark": "通过" }]
  // status  0待审 1通过 2驳回 
  data() {
    var validatePass2 = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请再次输入密码"));
      } else if (value !== this.formData.password) {
        callback(new Error("两次输入密码不一致!"));
      } else {
        callback();
      }
    };
    return {
      editStatusList: {
        0: '修改中，待审核',
        1: '已通过',
        2: '已驳回，要求修改'
      },
      uploadUrl: util.getUploadUrl("trademailcallback/upload"),
      checked: false,
      clearableFrom: true, //表单是否可以编辑
      machInfo: {
        editStatus: "",
      },
      auditFrom: {
        regRemark: "",
        fieldStatus: [],
        regStatus: 1,
        id: "",
      },
      // 上传图片列表对应关系
      fileList: {
        registerCertList: 'registerCert',
        companyPoliceList: "companyPolice",
        companyAgentPassportList: "companyAgentPassport",
        corporationCertList: "corporationCert",
        corporationDecisionList: "corporationDecision",
        nncList: "nnc",
        registerAddressCertList: "registerAddressCert",
        bankAccountNoCertList: "bankAccountNoCert",
        legalPersonCertList: "legalPersonCert",
        officeCertList: "officeCert",
        narList: "nar",
        corporation25PercentCertList: "corporation25PercentCert",
        corporation25PercentAddrCertList: "corporation25PercentAddrCert",
        enCompanyStructureList: "enCompanyStructure"
      },
      // 标记的修改数据
      checkedFrom: {
        email: false,
        code: false,
        url: false,
        fieldStatus: false,
        nar: false,
        legalPersonCert: false,
        isAgree: false,
        corporation: false,
        corporation: false,
        corporation: false,
        registerAddress: false,
        bankOpenBankNo: false,
        bankAccountNo: false,
        registerCertificateNo: false,
        mchName: false,
        mobile: false,
        beianNo: false,
        registerCert: false,
        companyPolice: false,
        companyAgentPassport: false,
        corporationCert: false,
        corporationDecision: false,
        registerAddressCert: false,
        bankAccountNoCert: false,
        officeCert: false,
        corporation25PercentCert: false,
        corporation25PercentAddrCert: false,
        enCompanyStructure: false,
      },
      formData: {
        email: undefined,
        code: undefined,
        password: undefined,
        confirmpassword: undefined,
        mobile: undefined,
        mchName: undefined,
        beianNo: undefined,
        url: undefined,
        registerCertificateNo: undefined,
        bankAccountName: undefined,
        bankAccountNo: undefined,
        swiftCode: undefined,
        bankOpenBankNo: undefined,
        registerAddress: undefined,
        corporation: undefined,
        phone: undefined,
        regCert: "",
        companyPolice: "",
        companyAgentPassport: "",
        corporationCert: "",
        corporationDecision: "",
        nnc: "",
        registerAddressCert: "",
        bankAccountNoCert: "",
        legalPersonCert: "",
        bankCapitalFlow: "",
        officeCert: "",
        nar: "",
        fieldStatus: [],
        corporation25PercentCert: "",
        corporation25PercentAddrCert: "",
        enCompanyStructure: "",
        registerCertList: [],
        companyPoliceList: [],
        companyAgentPassportList: [],
        corporationCertList: [],
        corporationDecisionList: [],
        nncList: [],
        registerAddressCertList: [],
        bankAccountNoCertList: [],
        legalPersonCertList: [],
        officeCertList: [],
        narList: [],
        corporation25PercentCertList: [],
        corporation25PercentAddrCertList: [],
        enCompanyStructureList: [],
      },
      rules: {
      },
      timer: null,
      count: "发送验证码",
    };
  },
  computed: {
    ...mapState("d2admin", {
      keepAlive: (state) => state.page.keepAlive,
      grayActive: (state) => state.gray.active,
      transitionActive: (state) => state.transition.active,
      asideCollapse: (state) => state.menu.asideCollapse,
      asideTransition: (state) => state.menu.asideTransition,
    }),
    ...mapState("d2admin/user", {
      user: "info",
    }),
    ...mapGetters("d2admin", {
      themeActiveSetting: "theme/activeSetting",
    }),
    /**
     * @description 最外层容器的背景图片样式
     */
    styleLayoutMainGroup() {
      return this.themeActiveSetting.backgroundImage
        ? {
          backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')`,
        }
        : {};
    },
  },
  watch: {
    $route() {
      console.log(this.$route)
      if (this.$route.name === 'mch-mchInfo') {
        this.id = this.$route.query.id; //获取传来的参数 
        this.getMchInfo() //路由变化时就重新执行这个方法 更新传来的参数
      }

    }
  },
  created() {
    _this = this
    this.getMchInfo()
  },
  activated() {
  },
  mounted() { },
  methods: {
    ...mapActions("d2admin/menu", ["asideCollapseToggle"]),
    async getMchInfo() {
      console.log(this.$route.query)
      let data = await ApiMain.info({ id: this.$route.query.id })
      this.machInfo = data
      this.translateFrom(data)
    },
    anewMch(index) {
      // 不等于1的话要处理表单回显
      this.auditFrom.fieldStatus = []
      Object.keys(this.checkedFrom).forEach(index => {
        if (this.checkedFrom[index]) {
          this.auditFrom.fieldStatus.push({ "label": index, "value": this.formData[index], "status": 1, "remark": "驳回" })
        }
      })

      if (this.auditFrom.fieldStatus.length == 0) return this.$message({ type: 'error', message: '请至少勾选一个需要更改内容!' })
      if (index != 1 && !this.auditFrom.regRemark) return this.$message({ type: 'error', message: '请填写拒绝原因!' })
      // 通过
      this.auditFrom.id = this.formData.id
      this.auditFrom.regStatus = index,
        this.auditFrom.editReviewRemark = this.auditFrom.regRemark
      this.auditFrom.editStatus = 2
      ApiMain.anewMch(this.auditFrom).then(res => {
        console.log(res)
        this.$message({ type: 'success', message: '审核成功!' })
        this.$router.go(-1)
        this.getMchInfo()
      })

    },

    editPassMch(index) {
      if (index != 1) {
        // 不等于1的话要处理表单回显
        this.auditFrom.fieldStatus = []
        Object.keys(this.checkedFrom).forEach(index => {
          if (this.checkedFrom[index]) {
            this.auditFrom.fieldStatus.push({ "label": index, "value": this.formData[index], "status": 1, "remark": "驳回" })
          }
        })
      }
      if (index != 1 && !this.auditFrom.regRemark) return this.$message({ type: 'error', message: '请填写拒绝原因!' })
      // 通过
      this.auditFrom.id = this.formData.id
      this.auditFrom.editReviewRemark = this.auditFrom.regRemark
      this.auditFrom.editStatus = index,
        ApiMain.anewMch(this.auditFrom).then(res => {
          console.log(res)
          this.$message({ type: 'success', message: '审核成功!' })
          this.$router.go(-1)
          this.getMchInfo()
        })

    },
    passMch(index) {
      if (index != 1) {
        // 不等于1的话要处理表单回显
        this.auditFrom.fieldStatus = []
        Object.keys(this.checkedFrom).forEach(index => {
          if (this.checkedFrom[index]) {
            this.auditFrom.fieldStatus.push({ "label": index, "value": this.formData[index], "status": 1, "remark": "驳回" })
          }
        })
      }
      if (index != 1 && !this.auditFrom.regRemark) return this.$message({ type: 'error', message: '请填写拒绝原因!' })
      // 通过
      this.auditFrom.id = this.formData.id
      this.auditFrom.regStatus = index,
        ApiMain.pass(this.auditFrom).then(res => {
          console.log(res)
          this.$message({ type: 'success', message: '审核成功!' })
          this.$router.go(-1)
          this.getMchInfo()
        })

    },
    //  回显表单方法 这个地方要复用

    translateFrom(from) {
      //   表单回显
      Object.keys(_this.fileList).forEach(function (index) {
        from[index] = []
        if (from[_this.fileList[index]]) {
          let arr = from[_this.fileList[index]].split(',')
          arr.forEach(file => {
            from[index].push({
              url: file,
              name: file
            })
          })
        }
      });


      this.formData = from

    },
    handleFileUploadsucceed(file, fileList, type) {
      this.formData[type] = fileList
    },
    handlePreview(file) {
      var a = document.createElement("a");
      var event = new MouseEvent("click");
      a.download = file.name;
      a.href = file.url;
      a.dispatchEvent(event);
    },
    async senEmailCode() {
      //   let data = await ApiMain.varifyEmail({ email: this.formData.email })
      //   if (data == 0) return this.$message({ type: 'error', message: '该邮箱已被注册！请更换邮箱' })
      //   ApiMain.getEmailCode({ type: 1, email: this.formData.email }).then(res => {
      //     this.$message({ type: 'success', message: '发送成功！' })
      //   })
      this.countDown()
    },
    countDown() {
      //发送验证码
      if (!this.timer) {
        this.count = 60;
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= 60) {
            this.count--;
          } else {
            clearInterval(this.timer);
            this.timer = null;
          }
        }, 1000);
      }
    },
    /**
     * 接收点击切换侧边栏的按钮
     */
    handleToggleAside() {
      this.asideCollapseToggle();
    },
    returnDisposeUrL(arr, index) {
      let str = ''
      try {
        // 过滤一下上传失败 element判断图片为一张是
        arr.forEach(item => {
          if (item.status == "success") {
            str += item.response.requestUrls[0] + ','
          }
        })
        str = str.substring(0, str.length - 1)
      } catch (error) {
        console.log('处理文件错误错误:', index, arr, error)
      }
      return str
    },
    async submitForm() {
      // 需要的字段
      let fieldList = ['email', 'code', "url", "beianNo", "mobile", "mchName", "registerCertificateNo", "bankAccountName", "bankAccountNo", "bankOpenBankNo", "registerAddress", "corporation", "corporation"
        , "corporation", "phone", "isAgree", "legalPersonCert", "fieldStatus", "nar", "registerCert", "companyPolice", "companyAgentPassport", "corporationCert", "corporationDecision"
        , "nnc", "registerAddressCert", "bankAccountNoCert", "officeCert", "corporation25PercentCert", "corporation25PercentAddrCert", "enCompanyStructure"]

      this.$refs["elForm"].validate(async (valid) => {
        if (!valid) return;
        Object.keys(_this.fileList).forEach(function (index) {
          _this.formData[_this.fileList[index]] = _this.returnDisposeUrL(_this.formData[index], index)
        });
        let updataFrom = {}
        fieldList.forEach(item => {
          updataFrom[item] = _this.formData[item]
        })
        // let start = await ApiMain.register(updataFrom)
        if (start.username) {
          this.$message({ type: 'success', message: '注册成功!' })
          this.$router.go(-1)
        }
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
    BeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 10;
      if (!isRightSize) {
        this.$message.error("文件大小超过 10MB");
      }
      return isRightSize;
    },
    handleFileChange(file, fileList) {
      this.file = fileList;
    },
    async handleFileUpload(params, type) {
      //   let data = await updataFileOss(params, type)
      return data.res
    },
  },
};
</script>
<style lang="scss" scoped>
.checkbox {
  margin-left: 20px;
  width: 100px;
}
.content {
  max-width: 90%;
}
.main {
  max-width: 1000px;
  margin: 0px auto;
}
.elForm {
  height: 100%;
  margin: 0px auto;
}
.el-upload__tip {
  line-height: 1.2;
}
.title {
  text-align: center;
  margin-top: 50px;
}
.title_sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .wire {
    width: 40%;
    height: 1px;
    background-color: rgb(227, 227, 227);
  }
}
.footer-btn {
  display: flex;
  justify-items: center;
  justify-content: center;
  margin-bottom: 100px;
}
.header-right {
  float: right;
  display: flex;
  justify-content: flex-end;
  padding-right: 100px;
  margin-top: 30px;
}
.updata-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
</style>
<style lang="scss">
// 注册主题
@import "~@/assets/style/theme/register.scss";

.uoloadSty .el-upload--picture-card {
  width: 148px;
  height: 148px;
  line-height: 146px;
}
.el-upload--picture-card {
  display: none !important; /* 上传按钮隐藏 */
}
</style>